<script type="text/javascript">
<!--
$(document).ready(function(){
							$('.tuan').hide();
							});
/*
$('.plus').live('click',function(){
							$id =$(this).attr('id');
							sotuan = $('#sotuan'+$id).val();
							$(this).attr('src','/img/minus.png');
							if(!isNaN(sotuan)){}
							else
								sotuan = 7;
							for (i=1;i<=sotuan;i++)
							{
								$('#tuan'+$id+$i).show(1000);
							}
							$(this).addClass('minus');
							$(this).attr('class','minus');
							});
$('.minus').live('click',function(){
							$id =$(this).attr('id');
							sotuan = $('#sotuan'+$id).val();
							$(this).attr('src','/img/plus.png');
							if(!isNaN(sotuan)){}
							else
								sotuan = 7;
							for (i=1;i<=sotuan;i++)
							{
								$('#tuan'+$id+$i).hide(1000);
							}
							$(this).attr('class','plus');
							});
*/
$('.plus').live('click',function(){
	root=$('#root').val();
	id =$(this).attr('id');
	sotuan = $('#sotuan'+id).val();
	$(this).attr('src',root+'img/minus.png');
	if(!isNaN(sotuan)){}
	else
		sotuan = 7;
	for (i=1;i<=sotuan;i++)
	{
		$('#tuan'+id+i).show(1000);
	}
	$(this).addClass('minus');
	$(this).attr('class','minus');
	});

$('.minus').live('click',function(){
	root=$('#root').val();
	$id =$(this).attr('id');
	sotuan = $('#sotuan'+id).val();
	$(this).attr('src',root+'img/plus.png');
	if(!isNaN(sotuan)){}
	else
		sotuan = 7;
	for (i=1;i<=sotuan;i++)
	{
		$('#tuan'+id+i).hide(1000);
	}
	$(this).attr('class','plus');
	});

//-->
</script>
<div id="tabs">
	<ul>
        <li id="current"><?php echo $this->Html->link(__('Kế hoạch tác nghiệp', true), array('controller' => 'z1chithikhs', 'action' => 'indexnv',$donvi)); ?> </li>
	</ul>
</div>
<?php
echo $form->create('Z1chithikhs'); 
echo $form->input('root',array('id'=>'root','type'=>'hidden','value'=>$this->webroot));
?>
<div class="z1chithikhs">
<h2><?php __('Kế hoạch tác nghiệp của '.$dv['Donvi']['tendv']);?></h2>
<p>
<?php
if(empty($nams))
		$nams =array();  
echo $form->input('nam',array('id'=>'nam','label'=>'Năm','options'=>$nams,'empty'=>"Chọn Năm",'selected'=>date('Y')));
?></p>
<div id='tbltg'>
<table cellpadding="0" cellspacing="0" id="tables">
<tr>
	<th><?php echo 'STT';?></th>
	<th><?php echo 'Thời gian';?></th>
	<th><?php echo 'Hành động';?></th>
    <th><?php echo 'Trạng thái';?></th>

</tr>
<?php
$i = 0;$sttthang = 0;
foreach ($z1chithikhthangs as $z1chithikhthang):
		$thanght = date('m',strtotime($z1chithikhthang['Z1chithikh']['ngaybd']));
		$class = null;
		$id=null;
		$align =null;
		/*
		if ($sttthang>0)
			echo $form->input('', array('type'=>'hidden','value'=>$stttuan,'id'=>'sotuan'.$sttthang));
		*/	
		$sttthang++;
?>
	<tr<?php echo $class;?>>
		<td>
			<?php echo $sttthang;//$z1chithikh['Z1chithikh']['id']; ?>
		</td>
		<td>
			<?php 
                	echo $html->image('/img/plus.png', array('class'=>'plus','id'=>0,'id'=>$sttthang));
                    echo '<strong>'.date('d/m/Y',strtotime($z1chithikhthang['Z1chithikh']['ngaybd'])).
                        ' - '.date('d/m/Y',strtotime($z1chithikhthang['Z1chithikh']['ngaykt'])).'</strong>';                  
            ?>
		</td>
		<td class="actions">
        <?php
        	echo $this->Html->link(__('Kế hoạch tháng', true), array('controller'=>'nvchithis','action' => 'index', $z1chithikhthang['Z1chithikh']['id'],$this->Session->read('cur_manv')));
      
        ?>
        
		</td>
        <td align='center'>
          <?php 
            if(empty($z1chithikhthang['Z1chithikh']['chithi']))
                $tb='Chưa có';
            else
                $tb='Đã tạo';
            echo $tb;
        ?>
        </td>
	</tr>
	
	
	<?php
		$stttuan=0;
		foreach ($z1chithikhtuans as $z1chithikhtuan):
		 	$thangoftuan = date('m',strtotime($z1chithikhtuan['Z1chithikh']['ngaybd']));
		 	$class = null;
			$id=null;
			$align =null;
		 if($thanght==$thangoftuan)
		 {
		 	$stttuan++;
		 	$class = ' class = tuan ';
			$id = ' id =tuan'.$sttthang.$stttuan;
			$align = ' align=right';
	?>
	<tr<?php echo $class.$id;?>>
		<td>
			<?php //echo $i//$z1chithikh['Z1chithikh']['id']; ?>
		</td>
		<td align='right'>
			<?php 
                    echo date('d/m/Y',strtotime($z1chithikhtuan['Z1chithikh']['ngaybd'])).
                        ' - '.date('d/mY',strtotime($z1chithikhtuan['Z1chithikh']['ngaykt']));
                  
            ?>
		</td>
		<td class="actions">
        <?php                                 
            echo $this->Html->link(__('Kế hoạch tuần', true), array('controller'=>'nvngays','action' => 'suanv', $z1chithikhtuan['Z1chithikh']['id'],$this->Session->read('cur_manv')));
        ?>
        
		</td>
        <td>
          <?php
            if(empty($z1chithikhtuan['Z1chithikh']['kh']))
                $tb='Chưa tạo';
            else if($z1chithikhtuan['Z1chithikh']['dagiao']==1)
                $tb='Đã giao';
            else if($z1chithikhtuan['Z1chithikh']['dagiao']==2)
                $tb='Đã duyệt';
            else
                $tb='Chưa giao';
                
        echo $tb;                      
           		       
        ?>
        </td>
	</tr>
	<?php
		 }
		endforeach;
		if ($sttthang>0)
			echo $form->input('', array('type'=>'hidden','value'=>$stttuan,'id'=>'sotuan'.$sttthang)); 
endforeach; ?>
</table>
</div>
</div>
<?php
$this->Js->get('#nam')->event('change',
								$this->Js->request(array('controller' => 'Z1chithikhs', 'action' => 'ajaxindexnv',$donvi),
								array('update' => '#tbltg','async' => true,
								'dataExpression' => true,'method' => 'post',
								'data' => $js->serializeForm(array('isForm' => true, 'inline' => true)))));
echo $form->end(); 
?>